package com.hoffm59.facebookcontactsync.util;

import android.content.Intent;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.view.View;
import android.widget.BaseAdapter;

/**
 * @author HOFFM59
 */
public abstract class BaseListElement {

    private final Drawable icon;
    private String text1;
    private String text2;
    private final int requestCode;

    private BaseAdapter adapter;

    public BaseListElement(Drawable icon, String text1, String text2, int requestCode) {

        super();
        this.icon = icon;
        this.text1 = text1;
        this.text2 = text2;
        this.requestCode = requestCode;
    }

    /**
     * @return the text1
     */
    public String getText1() {

        return this.text1;
    }

    /**
     * @param text1
     *            the text1 to set
     */
    public void setText1(String text1) {

        this.text1 = text1;
        if (this.adapter != null) {
            this.adapter.notifyDataSetChanged();
        }
    }

    /**
     * @return the text2
     */
    public String getText2() {

        return this.text2;
    }

    /**
     * @param text2
     *            the text2 to set
     */
    public void setText2(String text2) {

        this.text2 = text2;
        if (this.adapter != null) {
            this.adapter.notifyDataSetChanged();
        }
    }

    /**
     * @return the icon
     */
    public Drawable getIcon() {

        return this.icon;
    }

    /**
     * @return the requestCode
     */
    public int getRequestCode() {

        return this.requestCode;
    }

    public void setAdapter(BaseAdapter adapter) {

        this.adapter = adapter;
    }

    public abstract View.OnClickListener getOnClickListener();

    public void onActivityResult(Intent data) {

    }

    public void onSaveInstanceState(Bundle bundle) {

    }

    public boolean restoreState(Bundle savedState) {

        return false;
    }

    protected void notifyDataChanged() {

        this.adapter.notifyDataSetChanged();
    }
}